package edu.sctu.zhoumengxue.day201506.day20150602;

import java.util.List;

/**逻辑处理类
 * Created by user12 on 2015/6/8.
 */
public class DateUtil {

    private String ban="khhp;j";
    private SetTrianData setTrianData;
    private SetPeopleData people;
    /*构造函数*/
    public DateUtil(){
        setTrianData = new SetTrianData();
        people = new SetPeopleData();
    }
/*获取乘客*/
    public void getPeople(){

        List<PeopleAppbean> list = people.setPeopleData();
        for (PeopleAppbean people:list){

            if(people.isHas_card(false)){
                String problem = checkBag(people);
                System.out.println(problem);
                if(problem.contains("无")){
                    deductMoney(people);
                }
            }else {
                System.out.println("s");
            }
        }


    }


    /*判断包裹*/
    private String checkBag(PeopleAppbean people) {
        BagDeth bagdeth = new BagDeth(people,ban);
        if (bagdeth.checkBag()){

            return "包裹 有问题";
        }else {return checkBag(people);}
    }

    /*判断水是否有问题*/

    public String checkWater(PeopleAppbean people){

        BagDeth bagdeth = new BagDeth(people,ban);
        if(bagdeth.checkWater()){
            return "水有问题";
        }else {
            ifPrice(people);
            return "都无问题";
        }
    }
/*判断金额*/
    private void ifPrice(PeopleAppbean people) {
        if(people.getPrice()>2){
            System.out.println("进站");
        }else {
            new CardDeth(setTrianData.SetTrianDataline1()).setPrice(10,people);
            System.out.println("充值完成");
            ifPrice(people);
        }
    }

/*扣除金额*/
    private void deductMoney(PeopleAppbean people) {
        CardDeth cardDeth = new CardDeth(setTrianData.SetTrianDataline1());
        if(people.getPrice()>=cardDeth.getPrice(people.getStart(),people.getEnd())){
            System.out.println("出站，余额为："+(people.getPrice()-cardDeth.getPrice(people.getStart(),people.getEnd())));
        }else {
            cardDeth.setPrice(10,people);
            System.out.println("充值成功");
            deductMoney(people);
        }
    }

}
